Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't detatch Git HEAD when advance-branches is enabled for a branch #3405

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

emesterhazy
Copy link
Contributor

When setting the working copy commit, if a single branch points to a parent of the working copy and advance-branches is enabled for that branch, set Git HEAD to the branch instead of detatching at the parent commit.

## Feature Description

If enabled in the user or repository settings, the local branches pointing to the
parents of the revision targeted by `jj commit` will be advanced to the newly
created commit. Support for `jj new` will be added in a future change.

This behavior can be enabled by default for all branches by setting
the following in the config.toml:

```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
```

Specific branches can also be disabled:
```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
disabled-branches = ["main"]
```

Branches that match a disabled pattern will not be advanced, even if they also
match an enabled pattern.

This implements feature request #2338.
In a future commit these tests will run with both `jj commit` and `jj new` since
both will have the same semantics for advancing the branch pointer.

Parameterizing the tests allows us to run both variants without duplicating the
test bodies. Since the commit IDs are different when `jj describe` + `jj new`
is used instead of `jj commit`, this commit also drops the commit IDs from the
test snapshots. This is fine because the commit IDs are not important for these
tests.
When setting the working copy commit, if a single branch points to a parent of
the working copy and advance-branches is enabled for that branch, set Git HEAD
to the branch instead of detatching at the parent commit.
@emesterhazy emesterhazy force-pushed the advanceable-branches branch from 8a218d2 to f5c4305 Compare March 31, 2024 18:43
@emesterhazy emesterhazy force-pushed the advanceable-branches branch from f5c4305 to bf681cf Compare April 9, 2024 17:54
@emesterhazy emesterhazy force-pushed the advanceable-branches branch 2 times, most recently from 5e10eef to e67d6f7 Compare April 20, 2024 13:29
Base automatically changed from advanceable-branches to main April 20, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant